package ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOPeration{
    public void work(BookList bookList){
        Scanner scanner=new Scanner(System.in);
        System.out.println("借阅图书....");
        System.out.println("请输入你要借阅的书：");
        String name=scanner.nextLine();
        int currentsize= bookList.getUseSize();
        for (int c = 0; c < currentsize; c++) {
            Book book = bookList.getBooks(c);
            if(book.isBorrowed()==true){
                System.out.println("这本书已借出");
                return;
            }
            if (book.getName().equals(name)) {
                book.setBorrowed(true);
                System.out.println("借阅成功");
                return;
            }
        }
        System.out.println("没有找到你要借阅的书");
    }
}
